if(!jsx3.lang.Class.forName("tibco.admin.environments.localSvars.LocalSvars")) {

    jsx3.lang.Class.defineClass("tibco.admin.environments.localSvars.LocalSvars",
            jsx3.gui.Block,
            null,
            function (localSvars) {
				localSvars.prototype.isEditmode = false;
				localSvars.prototype.strID = null;
				localSvars.prototype.strNodeID = null;
				localSvars.prototype.strNodeName = null;


                localSvars.prototype.loadDetails = function(strID, strNodeID, strNodeName) {
					this.strID = strID;
					this.strNodeID = strNodeID;
					this.strNodeName = strNodeName;
					this.loadBtnStatus();
					var objService = tibco.admin.Main.loadService("tibco.admin", "tibco/admin/environments/localSvars/rules/getSvarsInNode.xml", "getSvarsInNode", "Get Local Substitution Variables");
					objService.name = this.strNodeName;
					objService.EntityID = this.strNodeID;
					objService.setEndpointURL(tibco.admin.util.ServiceHelper.getSubstitutionVarsEndpointURL());
					objService.subscribe(jsx3.net.Service.ON_SUCCESS, this, this.onCallGetSvarsInNodeSuccess);
					objService.doCall();
                }
				
				localSvars.prototype.onCallGetSvarsInNodeSuccess = function() {
					this.getDescendantOfName("mtxLocalSvars_56M").repaint();
					if(this.getDescendantOfName("mtxLocalSvars_56M").getSortedIds().length == 0){
						this.getDescendantOfName("blkNullLabel_56M").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
					}else{
						this.getDescendantOfName("blkNullLabel_56M").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
						
					}
                }

				localSvars.prototype.loadBtnStatus = function() {
					if(this.isEditmode){
						this.getDescendantOfName("btnEdit_56M").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
						this.getDescendantOfName("btnSave_56M").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
						this.getDescendantOfName("btnCancel_56M").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
						this.getDescendantOfName("mcIsGloab_56M").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
						//this.getDescendantOfName("mcGloabValue_56M").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
						this.getDescendantOfName("mcValue_56M").setValueTemplate(tibco.admin.Main.getServer().getDynamicProperty("@@Local Svars Value_56M"));
						this.getDescendantOfName("mcValue_56M").setCellPadding("", true);
						this.getDescendantOfName("mcValue_56M").setPadding("", true);
					}else{
						this.getDescendantOfName("btnEdit_56M").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
						this.getDescendantOfName("btnSave_56M").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
						this.getDescendantOfName("btnCancel_56M").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
						this.getDescendantOfName("mcIsGloab_56M").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
						//this.getDescendantOfName("mcGloabValue_56M").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
						this.getDescendantOfName("mcValue_56M").setValueTemplate("");
						this.getDescendantOfName("mcValue_56M").setCellPadding( tibco.admin.Main.getServer().getDynamicProperty("@addin@MatrixCell Padding"), true);
						this.getDescendantOfName("mcValue_56M").setPadding( tibco.admin.Main.getServer().getDynamicProperty("@addin@MatrixC Padding"), true);
					}
					this.getDescendantOfName("mtxLocalSvars_56M").repaint();
				}

				localSvars.callRevert = function(mcName) {
					var server = tibco.admin.Main.getServer();
					var objCDFDocument = server.getCache().getDocument(server.getJSXByName("mtxLocalSvars_56M").getXMLId());
					var objRec = objCDFDocument.selectSingleNode("//record[@McName_56M='" + mcName + "']");
					if(objRec) {
						objRec.setAttribute("McValue_56M", objRec.getAttribute("McGloabValue_56M"));
						objRec.setAttribute("McIsGloab_56M", "true");
					}
					server.getJSXByName("mtxLocalSvars_56M").repaint();
				}

				localSvars.callOnChange = function(inputobj,mcName) {
					var server = tibco.admin.Main.getServer();
					var objCDFDocument = server.getCache().getDocument(server.getJSXByName("mtxLocalSvars_56M").getXMLId());
					var objRec = objCDFDocument.selectSingleNode("//record[@McName_56M='" + mcName + "']");
					if(objRec) {
						objRec.setAttribute("McValue_56M", inputobj.value);
						if(inputobj.value == objRec.getAttribute("McGloabValue_56M")){
							objRec.setAttribute("McIsGloab_56M", "true");
						}else{
							objRec.setAttribute("McIsGloab_56M", "false");
						}
					}
					server.getJSXByName("mtxLocalSvars_56M").repaint();
				}

				localSvars.callOnClick = function(inputobj) {
					inputobj.focus();
				}

				localSvars.prototype.callBtnEditOnclick = function() {
					this.isEditmode = true;
                    if(!this.pluginObj.isInEditMode()) {
                        this.pluginObj.beginEditMode();
                    }
                    else {
                        this.pluginObj.endEditMode();
                    }
					this.loadBtnStatus();
				}

				localSvars.prototype.callBtnSaveOnclick = function() {
					var objService = tibco.admin.Main.loadService("tibco.admin", "tibco/admin/environments/localSvars/rules/setSvarsToNode.xml", "setSvarsToNode", "Set Local Substitution Variables Node");
					objService.name = this.strNodeName;
					objService.EntityID = this.strNodeID;
					objService.setEndpointURL(tibco.admin.util.ServiceHelper.getSubstitutionVarsEndpointURL());
					objService.subscribe(jsx3.net.Service.ON_SUCCESS, this, this.onSetSvarsToNodeSuccess);
					objService.doCall();
                }

				localSvars.prototype.onSetSvarsToNodeSuccess = function() {
					if(!this.pluginObj.isInEditMode()) {
                        this.pluginObj.beginEditMode();
                    }
                    else {
                        this.pluginObj.endEditMode();
                    }
					this.isEditmode = false;
					this.loadDetails(this.strID, this.strNodeID, this.strNodeName);
                }

				localSvars.prototype.callBtnCancelOnclick = function() {
                    if(!this.pluginObj.isInEditMode()) {
                        this.pluginObj.beginEditMode();
                    }
                    else {
                        this.pluginObj.endEditMode();
                    }
					this.isEditmode = false;
					this.loadDetails(this.strID, this.strNodeID, this.strNodeName);
				}

				localSvars.prototype.callRefreshOnclick = function() {
					this.loadDetails(this.strID, this.strNodeID, this.strNodeName);
				}
            })
}